package com.netease.image.video;

import android.app.AlertDialog.Builder;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.net.Uri;
import android.os.Handler;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

public class ab
  implements MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener
{
  private static final String a = "MovieViewControl";
  private static final int d = 60000;
  private static final int e = 120000;
  private static final int f = 300000;
  private static final String g = "com.android.music.musicservicecommand";
  private static final String h = "command";
  private static final String i = "pause";
  Handler b = new Handler();
  Runnable c = new w(this);
  private final VideoView j;
  private final View k;
  private final Uri l;
  private final ContentResolver m;
  private int n = -1;
  private boolean o = false;
  private MediaController p;

  public ab(View paramView, Context paramContext, Uri paramUri)
  {
    this.m = paramContext.getContentResolver();
    this.j = ((VideoView)paramView.findViewById(2131558451));
    this.k = paramView.findViewById(2131558452);
    this.l = paramUri;
    String str = this.l.getScheme();
    if (("http".equalsIgnoreCase(str)) || ("rtsp".equalsIgnoreCase(str)))
    {
      this.b.postDelayed(this.c, 250L);
      this.j.setOnErrorListener(this);
      this.j.setOnCompletionListener(this);
      this.j.setVideoURI(this.l);
      this.p = new MediaController(paramContext);
      this.j.setMediaController(this.p);
      this.j.requestFocus();
      Intent localIntent = new Intent("com.android.music.musicservicecommand");
      localIntent.putExtra("command", "pause");
      paramContext.sendBroadcast(localIntent);
      Integer localInteger = d();
      if (localInteger == null)
        break label324;
      AlertDialog.Builder localBuilder = new AlertDialog.Builder(paramContext);
      localBuilder.setTitle("resume_playing_title");
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = localInteger;
      localBuilder.setMessage(String.format("resume_playing_message", arrayOfObject));
      localBuilder.setOnCancelListener(new y(this));
      localBuilder.setPositiveButton("resume_playing_resume", new z(this, localInteger));
      localBuilder.setNegativeButton("resume_playing_restart", new aa(this));
      localBuilder.show();
    }
    while (true)
    {
      return;
      this.k.setVisibility(8);
      break;
      label324: this.j.start();
    }
  }

  private static int a(Cursor paramCursor, int paramInt)
  {
    int i1 = 0;
    try
    {
      int i2 = paramCursor.getInt(paramInt);
      i1 = i2;
      label14: return i1;
    }
    catch (SQLiteException localSQLiteException)
    {
      break label14;
    }
    catch (NumberFormatException localNumberFormatException)
    {
      break label14;
    }
  }

  private void a(int paramInt)
  {
    if (!a(this.l));
    while (true)
    {
      return;
      ContentValues localContentValues = new ContentValues();
      localContentValues.put("bookmark", Integer.toString(paramInt));
      try
      {
        this.m.update(this.l, localContentValues, null, null);
      }
      catch (SecurityException localSecurityException)
      {
      }
      catch (UnsupportedOperationException localUnsupportedOperationException)
      {
      }
      catch (SQLiteException localSQLiteException)
      {
      }
    }
  }

  private static boolean a(Uri paramUri)
  {
    String str1 = paramUri.getScheme();
    String str2 = paramUri.getAuthority();
    if (("content".equalsIgnoreCase(str1)) && ("media".equalsIgnoreCase(str2)));
    for (int i1 = 1; ; i1 = 0)
      return i1;
  }

  private Integer d()
  {
    Object localObject1;
    if (!a(this.l))
      localObject1 = null;
    while (true)
    {
      return localObject1;
      String[] arrayOfString = new String[2];
      arrayOfString[0] = "duration";
      arrayOfString[1] = "bookmark";
      try
      {
        Cursor localCursor = this.m.query(this.l, arrayOfString, null, null, null);
        if (localCursor != null)
          try
          {
            if (localCursor.moveToFirst())
            {
              int i1 = a(localCursor, 0);
              int i2 = a(localCursor, 1);
              if ((i2 < 120000) || (i1 < 300000) || (i2 > i1 - 60000))
              {
                localCursor.close();
                localObject1 = null;
                continue;
              }
              Integer localInteger = Integer.valueOf(i2);
              localObject1 = localInteger;
              localCursor.close();
              continue;
            }
          }
          finally
          {
            localCursor.close();
          }
      }
      catch (SQLiteException localSQLiteException)
      {
        localObject1 = null;
      }
    }
  }

  public void a()
  {
  }

  public void b()
  {
    this.b.removeCallbacksAndMessages(null);
    a(this.j.getCurrentPosition());
    this.n = this.j.getCurrentPosition();
    this.o = this.j.isPlaying();
    this.j.stopPlayback();
  }

  public void c()
  {
    if (this.n >= 0)
    {
      this.j.setVideoURI(this.l);
      this.j.seekTo(this.n);
      this.n = -1;
      if (this.o)
        this.p.show(0);
    }
  }

  public void onCompletion(MediaPlayer paramMediaPlayer)
  {
    a();
  }

  public boolean onError(MediaPlayer paramMediaPlayer, int paramInt1, int paramInt2)
  {
    this.b.removeCallbacksAndMessages(null);
    this.k.setVisibility(8);
    return false;
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.image.video.ab
 * JD-Core Version:    0.6.0
 */